home *** CD-ROM | disk | FTP | other *** search
-
- PASCAL S Syntax Diagrams
- (All words in caps are required key words)
-
-
- program
-
- ---> PROGRAM ---> identifier ---> ( ---> identifier list ---> ) ---> ; ---+
- |
- +-------------------------------------------------------------<-+
- |
- +--> block ------> .
-
-
- block
-
- --+---> CONST -------> identifier --------> = ---> constant ---> ; ---+
- | |
- +-<---------------------------------------------------------------<-+
- |
- +---> TYPE --------> identifier --------> = ---> type -------> ; ---+
- | |
- +-<---------------------------------------------------------------<-+
- |
- +---> VAR ---------> identifier list ---> : ---> type -------> ; ---+
- | |
- +-<---------------------------------------------------------------<-+
- |
- v
- |
- +-+-> PROCEDURE ---> identifier --------> formal parameter list ---+
- | ^ |
- v | |
- +-+-<----------- ; <------- block <---------- ; <-------------------+
- | |
- +---> FUNCTION ----> identifier ----> formal parameter list ---+ |
- | | |
- | +-<----------------------------------------------------+ |
- | | |
- | +---> : ----------> type identifier ---------------------->-+
- |
- +---> BEGIN -------> statement sequence -----> END ----->
-
-
- type
-
- --+-----------------------> type identifier --------------------------------+->
- | |
- +--> ARRAY --> [ -+> constant --> .. --> constant -+> ] --> OF --> type --+
- | | | |
- | +-------------- + <-------------+ |
- | |
- | +->-------------------------------------->-+ |
- | | | |
- +--> RECORD ---+-+-> identifier list ---> : ---> type -+--+-> END ------>-+
- | |
- +----------------------- ; <----------+
-
-
- formal parameter list
-
- +->--------------------------------------------------------------------->-+
- | |
- --+-> ( -+-+->-------+--> identifier list --> : --> type identifier -+-> ) -+->
- | | | |
- | +-> VAR --+ |
- | |
- +-<--------------------------------- ; <--------------------+
-
-
- identifier list
-
- -----------------+---> identifier ----+---------------------------->------->
- | |
- +--------- , <---------+
-
-
- identifier
-
- -----------------> letter -----+--->-----------+--------------------->------->
- | |
- +--- letter <---+
- | |
- +--- digit <---+
-
-
- statement sequence
-
- -----------------+---> statement ----+---------------------------->------->
- | |
- +--------- , <---------+
-
-
- statement
-
- --+--+-> variable -------------+--> := ----------------------------------->-+->
- | | | |
- | +-> function identifier --+ |
- | |
- +----> procedure identifier ----+---> actual parameter list ---+-------->-+
- | | | |
- | +--->--------------------------+ |
- | |
- +----> BEGIN ------> statement sequence ------> END -------------------->-+
- | |
- | +->------------------->-+ |
- | | | |
- +--> IF --> expression --> THEN --> statement -+-> ELSE --> statement -+--+
- | |
- | +--->-------------------------------+ |
- | | | |
- +-> CASE -> expression -> OF +-+-> constant +-> : -> statement +-+-> END -+
- | | | | |
- | +----- , <---+ | |
- | | | |
- | +--------------- ; <------------+ |
- | |
- +----> WHILE ----> expression ------> DO ------> statement ------------->-+
- | |
- +----> REPEAT ---> statement sequence ---> UNTIL ---> statement -------->-+
- | |
- +----> FOR ------> variable identifier ---> := ---> expression --+ |
- | | |
- | +----<----------------------------------------------------<-+ |
- | | |
- | +--+-> TO -------+--> expression ---> DO ---> statement ----------->-+
- | | | |
- | +-> DOWN TO --+ |
- | |
- +---->------------------------------------------------------------------>-+
-
-
- expression
-
- ---> simple expression --+---+---+---+---+---+------------------------->-+-->
- | | | | | | |
- v v v v v v |
- = <> < > >= <= |
- | | | | | | |
- +---+---+---+---+---+--> simple expression --->-+
-
-
- simple expression
-
- ---+-->-----+--> term ----+--->-----------------+----+----+---------->------>
- | | | | | |
- +--> + --+ | v v v
- | | | + - OR
- +--> - --+ | | | |
- +---- term <----------+----+----+
-
-
- term
-
- ------> factor -----------+--->------------+----+----+----+----+----->------>
- | | | | | |
- | v v v v v
- | * / DIV MOD AND
- | | | | | |
- +--- factor <----+----+----+----+----+
-
-
- factor
-
- ---+--> unsigned constant --------------------------------------------->-+-->
- | |
- +--> variable ------------------------------------------------------>-+
- | |
- +--> function identifier ------> actual parameter list ------------->-+
- | |
- +--> ( -------> expression ----> ) --------------------------------->-+
- | |
- +--> NOT -----> factor --------------------------------------------->-+
-
-
- actual parameter list
-
- ------> ( ------+---> expression ---+------> ) ---------------------->------>
- | |
- +-------- , <-------+
-
-
- variable
-
- ----> variable identifier ---+----+--->------------------------------>------->
- | |
- | +---> [ --+--> expression --+--> ] --+
- | | | | |
- | | +------- , <------+ |
- | | |
- | +---> . -----> field identifier -->--+
- | |
- +---<----------------------------------<--+
-
-
- constant
-
- ---+---+-->-----+-----+---> unsigned number ---------------->-+------>------>
- | | | | |
- | +--> + --+ | |
- | | | +---> constant identifier ------------>-+
- | +--> - --+ |
- | |
- +----------------------> ' ----> character ----> ' ------>-+
-
-
- unsigned constant
-
- ---+------> constant identifier ---------------------------->-+------>------>
- | |
- +------> unsigned number -------------------------------->-+
- | |
- +------> ' ----> character ----> ' ---------------------->-+
-
-
- unsigned number
-
- ---> unsigned integer ---+--->----------------------------------+->-+------->
- | | |
- +---> . ----> unsigned integer --+--->-+ |
- | | |
- v | |
- +---<-------------------------<--+ |
- | |
- +---> E --+-->-----+-> unsigned integer ->-+
- | |
- +--> + --+
- | |
- +--> - --+
-
-
- unsigned number
-
- ------------------------+-----> digit -----+------------------------->------>
- | |
- +-----<------------+
-
-
-
- The first 10 characters are significant in identifiers (variables)
-
- Types supported by PASCAL-S
-
- integer
- real
- boolean
- char
-
- Records and arrays are supported
-
-
- All standard builtin functions are supported
-
- abs atan chr cos
- eof eoln exp ln
- odd ord pred round
- sin sqr sqrt succ
- trunc
-
-
- Builtin procedures supported
-
- read
- readln
- write
- writeln
-
-
- Compiler/Interpreter options
-
- A comment that has the character '$' as its first character is used to
- specify compiler options. These take the form of a letter followed by
- a plus sign (option on) or a minus sign (option off). All options
- default to off. The following options are available:
-
- T : Symbol table to be printed (to list file)
- S : Run time stack printed (to list file) on entry to procedure
-
-
- Pascal-S Error Summary
-
- 0 undefined identifier
- 1 attempt at multiple definition
- 2 identifier expected (but not found)
- 3 'program' expected (but not found)
- 4 ')` expected (but not found)
- 5 ':' expected (but not found)
- 6 illegal symbol
- 7 error in formal parameters list
- 8 'of' expected
- 9 '(' expected
- 10 type error
- 11 '[' expected
- 12 ']' expected
- 13 '..' expected
- 14 ';' expected
- 15 error in function result type
- 16 '=' expected
- 17 expression must have boolean result
- 18 control variable must be of type variable
- 19 type conflict between control variable and expression
- 20 error in program parameter list
- 21 number too large
- 22 '.' expected
- 23 invalid expression type following case
- 24 illegal character
- 25 identifier of type constant expected
- 26 array index type conflict
- 27 type conflict in declaration of array index bounds
- 28 no such array
- 29 error on type of identifier
- 30 undefined type
- 31 no such record
- 32 boolean type expected
- 33 arithmetic type expected
- 34 integer type expected
- 35 invalid operator
- 36 actual/formal parameter type conflict
- 37 item must be of type variable
- 38 string expected
- 39 not enough actual parameters
- 40 no digits after decimal point
- 41 incorrect type
- 42 type real expected
- 43 integer expected
- 44 variable of constant expected
- 45 variable of procedure identifier expected
- 46 type conflict in operands
- 47 label type incompatable with selecting expression
- 48 incorrect type of expression for standard function
- 49 store overflow
- 50 constant expected
- 51 ';=' expected
- 52 'then' expected
- 53 'until' expected
- 54 'do' expected
- 55 'to' or 'down to' expected
- 56 'begin' expected
- 57 'end' expected
- 58 factor expected
-
-
- Pascal-S operation codes
- (These are shown in the list file when the T option is selected)
-
- Code x y Action
- 0 x y Load address
- 1 x y Load value
- 2 x y Load indirect
- 3 x y Update DISPLAY
- 4 not used
- 5 not used
- 6 not used
- 7 not used
- 8 y Standard functions (selected by 0 .. 18)
- 9 y Add y to the element on top of the stack
- 10 y Jump to y (unconditional)
- 11 y Jump to y if stack top false
- 12 y Jump to y (case table) and select entry
- 13 y Entry in case table ... NOT EXECUTABLE
- 14 y For loop entry test - UP
- 15 y For loop retry test - UP
- 16 y For loop entry test - DOWN
- 17 y For loop retry test - DOWN
- 18 y Mark stack
- 19 y Call user procedure
- 20 y Indexed fetch (element size <> 1)
- 21 y Indexed fetch
- 22 y Load block
- 23 y Copy block
- 24 y Load literal
- 25 y Load real
- 26 y Float
- 27 y Read (y denotes type .. 1 integer, 2 real, 4 char)
- 28 y Write string
- 29 y Write .. default field widths
- 30 y Write .. given field widths
- 31 HALT
- 32 Exit procedure
- 33 Exit function
- 34 Fetch
- 35 Not
- 36 Negate
- 37 Write real .. given field widths
- 38 Store
- 39 Real =
- 40 Real <>
- 41 Real <
- 42 Real <=
- 43 Real >
- 44 Real >=
- 45 Integer =
- 46 Integer <>
- 47 Integer <
- 48 Integer <=
- 49 Integer >
- 50 Integer >=
- 51 Or
- 52 + integer
- 53 - integer
- 54 + real
- 55 - real
- 56 And
- 57 * integer
- 58 Div
- 59 Mod
- 60 * real
- 61 /
- 62 Readln
- 63 Writeln
-
-
-
-
- A special thanks to Anthony Marcy and Phil Windley for their help
- on this project. If you should have and comments or improvements to
- the Pascal-S compiler/interpreter, please contact:
-
- John Naleszkiewicz
- (301)468-1439 (data)
- 6:30pm to 8:30am weekdays
- 24Hrs weekends.
-
-
-
- John Naleszkiewicz
- (301)468-1439 (dat